#ifndef DATAGRAM
#define DATAGRAM

#include "datagram_header.hpp"
#include <stdlib.h>

// using string as return maybe more easy to handle 
// but it will lost when in an accidenet,it meets a zero in mid

class Datagram
{
private:
    // keep the data offset a datagram_header size.
    char data_buffer[msg_onePieceSize];

    datagram_header header;

public:
    // make a datagram with type;
    Datagram(datagram_type type=type_empty);

    // make a datagram with the buffer which is a datagram
    Datagram(char* buffer);

    // input data to generate a datagram for transmit
    bool fillData(char* dataBuffer, int data_size,int seq);

    // get the datagram
    // of course with the datagram data size return
    int get(char* buffer);

    // get the datagram's header
    // of course with the datagram data size return
    datagram_header& getHeader();

    // get the datagram's data
    // of course with the datagram data size return
    int getData(char* buffer);
};


#endif